package com.bf.xpdd.persistent;

import java.io.IOException;
import java.io.Reader;

import org.apache.log4j.Logger;
import com.bf.xpdd.config.ConfigParameter;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

/**
 * 获取数据源
 * 
 * @author LiuChang
 * @version 1.0 2010-12-07
 * @since 1.0
 */
public class DaoConfig
{

	/** IBatis配置信息 */
	private static Reader reader;

	/** 数据库配置信息 */
	//private static Properties props;

	/** log4j */
	private static final Logger LOGGER = Logger.getLogger(DaoConfig.class);

	static
	{
		try
		{
			DaoConfig.reader = Resources
					.getResourceAsReader(ConfigParameter.IBATIS_CONFIG_MYSQL);
			/*
			 * File file = new File(SysConfig.DB_PROPERTIES); Properties prop =
			 * new Properties(); prop.load(new FileInputStream(file)); //
			 * DaoConfig.props = prop; DaoConfig.props = prop;
			 */
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

	}

	public static SqlMapClient getSqlMapClient() throws IOException
	{
		return SqlMapClientBuilder.buildSqlMapClient(Resources
				.getResourceAsReader(ConfigParameter.IBATIS_CONFIG_MYSQL)); //$NON-NLS-1$
	}

}
